package com.heima.user.controller.v1;

import com.heima.model.common.constans.admin.AdminConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.UserDto;
import com.heima.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("认证用户管理")
@RestController
@RequestMapping("api/v1/auth")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("查询所有用户")
    @PostMapping("/list")
    public ResponseResult findAllUserByPage(@RequestBody UserDto userDto) {
        return userService.findUserByPage(userDto);
    }

    @ApiOperation("自媒体用户审核驳回")
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody UserDto userDto) {
        return userService.updateStatusById(userDto, AdminConstants.FAIL_AUTH);
    }

    @ApiOperation("自媒体用户审核通过")
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody UserDto userDto) {
        return userService.updateStatusById(userDto,AdminConstants.PASS_AUTH);
    }


}
